package com.ostrich.module_home.nominate.adapter

import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.ostrich.module_home.R
import com.ostrich.module_home.nominate.adapter.provider.*
import com.ostrich.module_home.nominate.entity.NominateEntity

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/28 10:56
 * @Description : NominateAdapter
 */
class NominateAdapter:BaseProviderMultiAdapter<NominateEntity>() {

    init {
        addItemProvider(TextCardProvider(NominateItemType.TEXT_CARD_VIEW, R.layout.home_item_single_title_view))
        addItemProvider(VideoSmallCardProvider(NominateItemType.VIDEO_CARD_VIEW, R.layout.home_item_video_card_view))
        addItemProvider(FollowCardProvider( NominateItemType.FOLLOW_CARD_VIEW, R.layout.home_item_follow_card_view))
        addItemProvider(TitleProvider(NominateItemType.SQUARE_CARD_VIEW, R.layout.home_item_title_left_right_view))
        addItemProvider(EmptyProvider( NominateItemType.EMPTY_VIEW, R.layout.home_item_empty))

    }


    override fun getItemType(data: List<NominateEntity>, position: Int): Int {
        return when(data[position].type){
            "textCard" -> NominateItemType.TEXT_CARD_VIEW
            "videoSmallCard" -> NominateItemType.VIDEO_CARD_VIEW
            "followCard" -> NominateItemType.FOLLOW_CARD_VIEW
            "squareCardCollection" -> NominateItemType.SQUARE_CARD_VIEW
            else -> NominateItemType.EMPTY_VIEW

        }
    }
}